<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>行内块元素实现居中对齐</title>
    <style>
        div {
            text-align: center;
            width: 500px;
            height: 400px;
            border: 1px solid black;
        }

        span {
            background-color: yellow;
        }
    </style>
</head>

<body>
    <div>
        <span>里面有东西</span>
    </div>
</body>

</html>